//
//  EFGoodsDetailViewCellCart.m
//  EnjogFood
//
//  Created by guocheng on 2017/5/26.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFGoodsDetailViewCellCart.h"
#import "EFGoodsDetailViewItemCart.h"
#import "EFGoodScaleViewItem.h"
#import "EFGoodsModelItem.h"

@interface EFGoodsDetailViewCellCart()

@property(strong,nonatomic)UILabel* contentLabel;
@property(strong,nonatomic)UIImageView* moreIV;

@end

@implementation EFGoodsDetailViewCellCart



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor clearColor];
        self.backgroundColor = [UIColor whiteColor];
        [self initView];
    }
    return self;
}

-(void)setObject:(EFGoodsDetailViewItemCart *)item{
    NSMutableString* strModels = [[NSMutableString alloc] init];
    for (EFGoodsModelItem *goodsModelItem in  item.scaleView.model) {
        if(goodsModelItem.select){
            NSString* strTemp = [NSString stringWithFormat:@"\"%@\",",goodsModelItem.model_value];
            [strModels appendString:strTemp];             }
    } 
    
    NSString* strContent = [NSString stringWithFormat:@"已选 ：%@\"%ld份\"",strModels,item.count];
    [self.contentLabel setText:strContent];
    [self.contentLabel sizeToFit];
    self.contentLabel.top = 17;
    self.contentLabel.left = 20;

}

-(void)initView{
    [self.contentView addSubview:self.contentLabel];
    [self.contentView addSubview:self.moreIV];
}


-(void)moreIVTapAction{
    if(self.moreblock != NULL){
        self.moreblock();
    }
} 

- (UILabel *)contentLabel{
    if (!_contentLabel) {
        _contentLabel = [[UILabel alloc] init];
        _contentLabel.backgroundColor = [UIColor clearColor];
        _contentLabel.font = [UIFont systemFontOfSize:13.f];
        _contentLabel.textColor = kBlack999;
    }
    return _contentLabel;
}


-(UIImageView *)moreIV{
    if(_moreIV == NULL){
        _moreIV = [[UIImageView alloc ] initWithFrame:CGRectMake(0, 0, 20, 20)];
        [_moreIV setImage:IMG(@"more_icon_me_default")];
        _moreIV.left = kScreenWidth - _moreIV.width - 20;
        _moreIV.top = 14;
        
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(moreIVTapAction)];
        [self.moreIV addGestureRecognizer:tapGesture];
        self.moreIV.userInteractionEnabled = YES;
    }
    return _moreIV;
}

@end
